package model;

import java.util.Observable;
import java.util.ArrayList;
import java.util.HashMap;

import utils.User;
import utils.Date;
import utils.Dish;
import utils.Time;

public class Delivery extends Observable {
	private HashMap<String, String> deliveryInfos;
	private ArrayList<Dish> deliveryElements;
	private String restaurant;
	private String deliveryConfirmationNumber;
	private float price;
	private float taxes;
	private float totalPrice;

	public Delivery() {
		deliveryElements = new ArrayList<Dish>();
		deliveryInfos = new HashMap<String, String>();
		setDeliveryInfo("Civic address", User.CIVICADDRESS);
		setDeliveryInfo("City", User.CITY);
		setDeliveryInfo("Postal code", User.ZIPCODE);
		setDeliveryInfo("Province", User.PROVINCE);
		setDeliveryInfo("Country", User.COUNTRY);
		setDeliveryInfo("Date", Date.getDate());
		setDeliveryInfo("Time", Time.getTime());
	}

	public void setDeliveryConfirmNumber(String confirmNumber) {
		deliveryConfirmationNumber = confirmNumber;
	}

	public String getDeliveryConfirmNumber() {
		return deliveryConfirmationNumber;
	}

	public void setRestaurantName(String name) {
		restaurant = name;
	}

	public String getRestaurantName() {
		return restaurant;
	}

	public void setAllDeliveryInfos(HashMap<String, String> hm) {
		deliveryInfos = hm;
	}

	public void setDeliveryInfo(String key, String value) {
		deliveryInfos.remove(key);
		deliveryInfos.put(key, value);
	}

	public String getDeliveryInfo(String index) {
		return deliveryInfos.get(index);
	}

	public HashMap<String, String> getDeliveryInfos() {
		return deliveryInfos;
	}

	public void setAllDeliveryElements(ArrayList<Dish> list) {
		deliveryElements = list;
	}

	public ArrayList<Dish> getDeliveryElements() {
		return deliveryElements;
	}

	public void addDeliveryElement(Dish d) {
		deliveryElements.add(d);

		setChanged();
		notifyObservers(deliveryElements);
	}

	public void removeDeliveryElement(int index) {
		deliveryElements.remove(index);

		setChanged();
		notifyObservers(deliveryElements);
	}

	public void removeAllDeliveryElements() {
		deliveryElements.clear();

		setChanged();
		notifyObservers(deliveryElements);
	}

	public void setPrice(float p) {
		price = p;
	}

	public float getPrice() {
		return price;
	}

	public void setTaxes(float t) {
		taxes = t;
	}

	public float getTaxes() {
		return taxes;
	}

	public void setTotalPrice(float tp) {
		totalPrice = tp;
	}

	public float getTotalPrice() {
		return totalPrice;
	}
}
